package com.yds.workmanager.worker

import android.content.Context
import android.util.Log
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import java.lang.Exception

/**
 * 作者:     YDS
 * 创建时间: 2025/7/11 15:31
 * 页面描述: 压缩图片
 */
class ImageCompressWorker(context: Context, parameters: WorkerParameters) : CoroutineWorker(context, parameters) {
    override suspend fun doWork(): Result {
        return try {
            val imagePath = inputData.getString("image_path") ?: return  Result.failure()
            Log.i("YDSimon", "处理压缩图片操作...$imagePath")
            Result.success(workDataOf("image_compress_path" to "sdcard/images/compress.png"))
        } catch (e: Exception) {
            Log.i("YDSimon", "处理压缩图片操作,Exception...")
            Result.retry()
        }
    }

}